#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <iterator>
#include <functional>
#include <boost/bind.hpp>
#include <boost/timer.hpp>
#include <boost/shared_ptr.hpp>

using namespace std;

int hash(string s, int prime = 3943)
{
	const char *p = s.c_str();
	int h = 0;
	while(*p)
	{
		h = 5*h + *p++; 
		h %= prime;
	}

	return h;
}

int hash(const char *s, int prime = 3943)
{
	const char *p = s;
	int h = 0;
	while(*p)
	{
		h = 5*h + *p++; 
		h %= prime;
	}

	return h;
}

int main(int argc, char **argv)
{
	string s;
	ifstream in(argv[1]);
	map<int,int> M;

        while(in>>s)
		++M[hash(s)];

	map<int,int>::iterator pos = M.begin();
	while( pos != M.end() )
	{
		cout<<pos->first<<"  <->  "<<pos->second<<endl;
		++pos;
	}

	return 0;
}
